package com.song.controller;

import com.song.service.RoleService;
import com.song.service.UserService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * @author TonySong
 * @date 2024/4/23 0023
 * @time 15:33
 */
@Controller
@RequestMapping("/users")
public class UserController {

    @Resource
    private UserService userService;

    @Resource
    private RoleService roleService;


    @GetMapping("/list")
    public String getUser(Model model){
        model.addAttribute("users",userService.getAll());
        return "list";
    }

    @GetMapping("/add")
    public String toadd(Model model){
         //封装角色集合
        model.addAttribute("roles",roleService.getAllRole());
        return "add";
    }
}
